package com.itzxx.huazhun.ui

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter

class ViewPagerFragmentStateAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
    FragmentStateAdapter(fragmentManager, lifecycle) {

    private val mDataList = mutableListOf<Fragment>()
    override fun getItemCount(): Int {
        return mDataList.size
    }

    override fun createFragment(position: Int): Fragment {
        return mDataList[position]
    }

    fun addFragment(fragment: Fragment){
        mDataList.add(fragment)
    }

    fun getDataList(): List<Fragment> {
        return mDataList
    }
}